package cn.myjerry.server.demo1;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server5 {
	private ServerSocket server;
	
	public static final String CRLF = "\r\n";
	public static final String BLANK = " ";
	
	public static void main(String[] args) {
		Server5 server = new Server5();
		server.start();
	}
	
	public void start() {
		try {
			server = new ServerSocket(8888);
			
			this.receive();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	private void receive() {
		try {
			Socket client = server.accept();
			Request req = new Request(client.getInputStream());
			Response res = new Response(client.getOutputStream());
			
			Servlet serv = new Servlet();
			serv.service(req, res);
			
			res.pushToClient(200);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void stop() {
		
	}
}
